<template>
    <view>
        <c-list-filter ref="filter" @filter="onFilter" @sxfilter="sxfilter" :searchshow="searchshow"></c-list-filter>
        <view class="ptr-list" :class="{ ptrsearch: searchshow }">
            <view v-for="(item, index) in zwlist" v-if="zwlist && zwlist.length > 0" :key="index">
                <li-aunty :item="item" page="gs-recommend" :publish_id="publish_id"></li-aunty>
                <view></view>
            </view>
            <view class="nova-column nova-flex-center recommend-nothing" v-if="zwlist.length == 0">
                <image src="../../static/gs/recommend-empty.png" />
                <text>未匹配到阿姨信息</text>
                <text class="btn-more" @click="apiMoreAunty">去网上找更多阿姨</text>
            </view>
        </view>
    </view>
</template>

<script>
import cListFilter from '../c/c-list-filter.vue';
import liAunty from '../c/li-aunty.vue';
export default {
    components: {
        cListFilter,
        liAunty
    },
    props: {
        searchshow: {
            // 输入框是否显示
            type: Boolean,
            default: true
        }
    },
    data() {
        return {
            publish_id: '',
            reload: false,
            zwlist: [],
            form: {
                pagenum: 10,
                pages: 0,
                type: 0,
                area: '',
                place: '',
                city: ''
            }
        };
    },
    methods: {
        async loadData() {
            this.form.pages++;
            let res = await this.$request.post({
                url: '/house/recommendNurse',
                data: this.form
            });
            if (this.reload) {
                this.zwlist = res || [];
            } else {
                this.zwlist = this.zwlist.concat(res);
            }
            this.reload = false;
            uni.stopPullDownRefresh();
        },
        refresh() {
            this.reload = true;
            this.form.pages = 0;
            this.$refs.filter.setQY();
            this.loadData();
        },
        loadMore() {
            this.loadData();
        },
        show() {
            if (this.zwlist === undefined || this.zwlist.length == 0) {
                this.refresh();
            }
        },
        onFilter(e) {
            console.log('filter', e);
            Object.assign(this.form, e);
            this.zwlist = []
            this.form.pages = 0;
            this.loadData();
        },
        sxfilter() {
            this.$emit('sxfilter', this.form);
        },
        async apiMoreAunty() {
            let res = await this.$request.post({
                url: '/publish/toLookNurse',
                data: {
                    publish_id: this.publish_id
                }
            })
            this.$toast('推送成功')
        }
    },
    onLoad(options) {
        this.publish_id = options.publish_id || '';
        this.form.publish_id = this.publish_id
        this.loadData();
    }
};
</script>

<style></style>
